package org.csmzxy.class2333;

import java.util.Scanner;

public class GCDandLCM {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.print("请输入第一个正整数: ");
        int num1 = scanner.nextInt();

        System.out.print("请输入第二个正整数: ");
        int num2 = scanner.nextInt();

// 计算最大公约数（GCD）
        int gcd = findGCD(num1, num2);

// 计算最小公倍数（LCM）
        int lcm = (num1 * num2) / gcd;

        System.out.println("最大公约数（GCD）: " + gcd);
        System.out.println("最小公倍数（LCM）: " + lcm);

        scanner.close();
    }

    
    public static int findGCD(int a, int b) {
        while (b != 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }
}
